﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Web;

/// <summary>
/// Summary description for AppObjects
/// </summary>
public class AppObjects
{
    public AppObjects()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}

public class ServerData
{
    public List<ServerDisks> disks { set; get; }
    public List<ServerCPU> cpu { set; get; }
    public List<ServerMemory> memory { set; get; }
    public List<ServerServices> services { set; get; }
    public List<MessageQueue> messageQ { set; get; }

    public ServerData()
    {
    }
}
public class ServerInfo
{
    public string serverName { set; get; }
    public string userName { set; get; }
    public string passWord { set; get; }
    public string DisplayName { get; set; }
    public string getServices { set; get; }
    public string getDisks { set; get; }
    public string getMessages { set; get; }
    public string getCPU { set; get; }
    public string getMemory { set; get; }

    public ServerInfo()
    {
    }
    public ServerInfo(string servername, string username, string password, string displayname)
    {
        serverName = servername;
        userName = username;
        passWord = password;
        DisplayName = displayname;
    }
}
public class ServerDisks
{
    public String DiskName { get; set; }
    public String Status { get; set; }
    public Int64 TotalSpace { get; set; }
    public Int64 FreeSpace { get; set; }

    public ServerDisks()
    {
        // TODO: Complete member initialization
    }
}


public class ServerServices
{
    public String ServiceName { get; set; }
    public String Status { get; set; }
    public string StartMode { get; set; }
    public ServerServices()
    {
        // TODO: Complete member initialization
    }
}

public class ServerMemory
{
    public Int64 TotalVisibleMemorySize { get; set; }
    public Int64 FreePhysicalMemory { get; set; }

    public ServerMemory()
    {
        // TODO: Complete member initialization
    }
}

public class ServerCPU
{
    public Int64 CPULoadPercentage { get; set; }

    public ServerCPU()
    {
        // TODO: Complete member initialization
    }
}

public class MessageQueue
{
    public string QueueName { get; set; }
    public int NumberOfMessages {get;set;}

    public MessageQueue()
    {
        // TODO: Complete member initialization
    }
}
public static class Logger
    {
    
    public static void LogError(Exception e, string message)
    {
        string todaysDate = DateTime.Now.ToString("yyyyMMdd");
        string path = HttpContext.Current.Server.MapPath(string.Format( "~/Data/ErrorLog{0}.txt",todaysDate));
        
        using (StreamWriter sw = File.AppendText(path))
        {
            sw.WriteLine(string.Format("{0}\tMsg:{1}\t{2}\tCause:{3}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),e.Message,e.Source,message));
        }
    }

   }